package service

import (
	"fitness/internal/dao"
	"fitness/pkg/tools"
	"go.uber.org/zap"
)

type ServiceContainer struct {
	UserService  *UserService
	LoginService *LoginService
	MenuService  *MenuService
	DeptService  *DeptService
	DictService  *DictService
	RoleService  *RoleService
	LogService   *LogService
}

// CreateServiceInstance  创建单例
func CreateServiceInstance(daoContainer *dao.DaoContainer, handlerError *tools.HandlerError, logger *zap.Logger) *ServiceContainer {
	userService := NewUserService(
		daoContainer.SysUserDao,
		daoContainer.SysUserRolesDao,
		daoContainer.SysRoleDao,
		daoContainer.SysRoleMenuDao,
		handlerError)

	loginService := NewLoginService(daoContainer.SysUserDao, daoContainer.SysUserRolesDao, handlerError)
	menuService := NewMenuService(daoContainer.SysUserDao, daoContainer.SysMenuDao, logger)
	deptService := NewDeptService(daoContainer.DeptDao, logger)
	dictService := NewDictService(daoContainer.SysDictDao, logger)
	roleService := NewRoleService(daoContainer.SysRoleDao, logger)
	logService := NewLogService(daoContainer.LogDao, logger)
	return &ServiceContainer{
		UserService:  userService,
		LoginService: loginService,
		MenuService:  menuService,
		DeptService:  deptService,
		DictService:  dictService,
		RoleService:  roleService,
		LogService:   logService,
	}
}
